#include <iostream>
#include <signal.h>
#include <unistd.h>


volatile int flag = 0;

void change(int signo)//信号捕捉的执行流
{
    (void)signo;
    flag = 1;
    printf("change flag 0->1, getpid: %d\n",getpid());
}

int main()
{
    printf("I am main process, pid is : %d\n",getpid());
    signal(2,change);
    while(!flag)//主执行流
    {

    }
    printf("我是正常退出的!\n");
    return 0;
}
